package com.hl.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class GeneralResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public static GeneralResult success(){
        return new GeneralResult(200,"请求成功",null);
    }
    public static GeneralResult success(String msg){
        return new GeneralResult(200,msg,null);
    }
    public static GeneralResult success(List data){
        return new GeneralResult(200,"请求成功",data);
    }
    public static GeneralResult fail(){
        return new GeneralResult(406,"操作失败",null);
    }
    public static GeneralResult fail(Integer code){return new GeneralResult(code,"登陆失败",null);}
    public static <T> GeneralResult<T> success(String msg, T data){return new GeneralResult<>(200,msg,data);}


    public static <T>GeneralResult message(Integer code, String msg, T data) {
        return new GeneralResult(code,msg,data);
    }
}
